package it.avantsoft.ls.gl.command;

import it.avantsoft.ls.gl.GroupChildHandler;

public class AckNewChildCommand extends SynchronousCommand {
    private String newChildId;
    private String groupLeaderHost;
    private int groupLeaderListeningPort;


    public AckNewChildCommand(GroupChildHandler child, String newChildId, String groupLeaderHost, int groupLeaderListeningPort) {
        super(child);
        this.newChildId = newChildId;
        this.groupLeaderHost = groupLeaderHost;
        this.groupLeaderListeningPort = groupLeaderListeningPort;

    }

    public void execute() {
        getChild().ackNewChild(newChildId, groupLeaderHost, groupLeaderListeningPort);
    }

    public byte getCommandByte() {
        return ACK_NEW_CHILD;
    }

    public String toString() {
        return "AckNewChildCommand{" +
                "child=" + getChild() +
                ", newChildId='" + newChildId + '\'' +
                ", groupLeaderHost='" + groupLeaderHost + '\'' +
                ", groupLeaderListeningPort=" + groupLeaderListeningPort +
                '}';
    }
}
